<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); 
  class Coach extends CI_Controller {
    public $error;
    function __construct()
        {
       parent::__construct();
         $this->load->library('Auth');
         $this->load->helper('access_helper');
         
         $this->load->library('View');
         $this->view->setlayout('themplates/astyle/layout');
         $this->view->setTheme('themplates/astyle');
         $this->load->model('render_model', 'render');
         
         $this->load->model('coach_model', 'coach');
         
    }
    
    function index()
    {
 
 
        //$this->coach->_convert();
        $this->view->setTitle('Тренерская страничка');
        $this->render->prepare_view();
        if ($this->auth->hasAccess('coach'))
        {
            
            $this->view->set('scout_list', $this->coach->parseScoutList($this->coach->get_all()));
            $this->view->set('error',$this->error);
            $this->view->render('coach_view');
        }
        else 
        {
        $this->view->render('/blocks/access_error');    
        }
    }
    
    function scouts($action='', $userID='')
    {
        $i=0;
        switch ($action)
        {
            case 'add':
                if ($this->input->post('add_scout')) $action='add_scout';
                elseif ($this->input->post('add_coach')) $action='add_coach';
                $userID=$this->input->post('addID');
                $flag=true;
                break;
            case 'scout':
            case 'coach':
            case 'del':$flag=true;
                break;
            
        }
        if ($flag)
            { 
            if (!$this->coach->update_scout($userID, $action)) 
                {
                $this->error='Неудачно';
                }
            }
        $this->index();
    }
    
     
  }
?>